#include "Pipe.hpp"

int main()
{
    PipeFifo fifo;
    fifo.Build();
    int fd = fifo.OpenFile(ReadOpen);
    char buffer[128];
    //问题:这个代码的缓冲区没有被清空
    while(true)
    {
        ssize_t n = read(fd, buffer, sizeof buffer - 1);//必须留一个位置来放\0
        if(n == 0)//表示读到了文件结尾,此时写进程一定关闭了
        {
            break;
        }
        std::cout << buffer << std::endl;
        buffer[0] = 0;//将首位置为0,清空用户级缓冲区
        memset(buffer, 0, sizeof buffer);
    }

    fifo.Delete();
    return 0;
}